<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec"
           uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<sec:authentication property="principal" var="currentPrincipal"
                    scope="page"/>

<fmt:setBundle basename="ApplicationMessage"/>
<fmt:setLocale value="zh_CN"/>

<!DOCTYPE html>
<html lang="zh-CN">
<head>

    <%@ include file="/WEB-INF/include/meta.jsp" %>
    <%@ include file="/WEB-INF/include/css.jsp" %>

</head>

<body class="ms-theme-blue">

<%@ include file="/WEB-INF/include/header.jsp" %>
<%@ include file="/WEB-INF/include/submenu.jsp" %>

<div class="container-fluid ms-container has-ms-sidemenu">

    <ol class="ms-breadcrumb breadcrumb">
        <li class="active">客户列表&nbsp;&nbsp;-&nbsp;&nbsp;客户详情</li>
        <a class="pull-right" href="${ctx.host}/clients/${client.id}/edit" data-target="#edit" data-toggle="modal">修改基本信息</a>
    </ol>

    <div class="ms-content-layout ">
        <div class="form-horizontal ms-form ">
            <div class="form-group ms-form-group">
                <label class="control-label col-xs-2">EMAL：</label>
                <div class="col-xs-2">
                    <p class="form-control-static">${client.email}</p>
                </div>
                <label class="control-label col-xs-2">联系人：</label>
                <div class="col-xs-2">
                    <p class="form-control-static">${client.contacts}</p>
                </div>
            </div>
            <div class="form-group ms-form-group">
                <label class="control-label col-xs-2">联系手机：</label>
                <div class="col-xs-2">
                    <p class="form-control-static">${client.phone}</p>
                </div>
                <label class="control-label col-xs-2">客户类型：</label>
                <div class="col-xs-2">
                    <p class="form-control-static"><c:forEach items="${client.types}" var="t"> ${t.description} </c:forEach></p>
                </div>
            </div>
            <div class="form-group ms-form-group">
                <label class="control-label col-xs-2">公司名称：</label>
                <div class="col-xs-2">
                    <p class="form-control-static">${client.companyName}</p>
                </div>
                <label class="control-label col-xs-2">录入人：</label>
                <div class="col-xs-2">
                    <p class="form-control-static">${client.principal.name}</p>
                </div>
            </div>
            <div class="form-group ms-form-group">
                <label class="control-label col-xs-2">录入时间：</label>
                <div class="col-xs-2">
                    <p class="form-control-static"><fmt:formatDate value="${client.createTime}"
                                                                   pattern="yyyy-MM-dd"></fmt:formatDate></p>
                </div>

            </div>
            <div class="form-group ms-form-group">
                <label class="control-label col-xs-2">备注：</label>
                <div class="col-xs-4">
                    <textarea class="form-control-static" readonly style="min-width: 100%;min-height: 100px">${client.remarks}</textarea>
                </div>
            </div>
        </div>

        <c:if test="${not empty client.agent}">

            <div class="block-heading">
                <h5>代理统计</h5>
            </div>

            <div class="form-horizontal ms-form ">

                <div class="form-group ms-form-group">
                    <label class="control-label col-xs-2">当前绑定代理：</label>
                    <div class="col-xs-2">
                        <p class="form-control-static">${client.agent.name} ${client.agent.company.companyName}</p>
                    </div>
                    <label class="control-label col-xs-2">租车销售额：</label>
                    <div class="col-xs-2">
                        <p class="form-control-static"><fmt:formatNumber value="${sales / 100}" maxFractionDigits="0"></fmt:formatNumber>人民币</p>
                    </div>
                </div>
            </div>
        </c:if>

        <div class="block-heading">
            <h5>访谈列表</h5>
        </div>

        <div class="form-horizontal ms-form ">
            <table class="table table-hover ms-table">
                <thead>
                <tr>
                    <th>序号</th>
                    <th>联系人</th>
                    <th>联系电话</th>
                    <th>联系邮件</th>
                    <th>销售</th>
                    <th>访谈时间</th>
                    <th>访谈地点</th>
                    <th>内容概要</th>
                    <th></th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${clientInterviewRecords}" var="cir" varStatus="status">
                    <tr>
                        <td>${status.index + 1}</td>
                        <td>${cir.client.contacts}</td>
                        <td>${cir.client.phone}</td>
                        <td>${cir.client.email}</td>
                        <td>${cir.client.principal.name}</td>
                        <td><fmt:formatDate value="${cir.interviewTime}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                        <td>${cir.interviewLocation}</td>
                        <td>${cir.interviewSummary}</td>
                        <td><a href="${ctx.host}/client-interview-records/${cir.id}">详情</a></td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>

    </div>
</div>
<%@ include file="/WEB-INF/include/script.jsp" %>
<d:resource type="script" root="${ctx.resource}/build" src="js/page/data/client-list.js"/>
<script type="text/javascript">
    require(['page/data/client-list'], function (page) {
        page.init();
    })
</script>
</body>
</html>